package com.wowangz.cms.common.utils;

import java.util.List;

import com.wowangz.cms.common.pojo.DataDictionaryInfo;
import com.wowangz.cms.common.select.BaseSelect;
import com.wowangz.cms.common.select.SelectFactory;

@SuppressWarnings("rawtypes")
public class DictTypeConstant {

	public static final String STOREINDUSTRY = "StoreIndustry"; // 商户行业

	public static final String NAME_STOREINDUSTRY = "商户行业";

//	public static String getName(String arg0) {
//		String name = "";
//		if (STOREINDUSTRY.equals(arg0)) {
//			name = NAME_STOREINDUSTRY;
//		}
//
//		return name;
//	}

	public static final String POPULATION = "StorePopulation";
	public static final String QUALITY = "StoreQuality";
	
	/**
	 * 获取单个数据字典下拉框
	 * 
	 * @param dictTypeCode
	 *            数据字典类型编码
	 * @param all
	 *            是否需要增加一个值为空的内容为全部的选项
	 * @param none
	 *            是否需要增加一个值为空的内容为空格的选项
	 * @return
	 */
	public final static String getDataDictionaryInfoSelectList(String dictTypeCode, boolean all, boolean none) {
		List<DataDictionaryInfo> list = DataDictionaryManage.getDataDictionaryMap().get(dictTypeCode);
		BaseSelect baseSelect = SelectFactory.createBaseSelect();
		if (all)
			baseSelect.addAllEmpty();
		if (none)
			baseSelect.addNoneEmpty();
		for (DataDictionaryInfo dic : list) {
			baseSelect.addOption(dic.getDictCode(), dic.getDictName());
		}
		return baseSelect.getJSONSelectInfo();
	}

	/**
	 * CardTypeName
	 * 
	 * @param dictType
	 *            CardTypeName
	 * @param dictattr
	 *            数据属性
	 * @return 根据用户选择的卡类型 选择其下所有卡种名称
	 */
	public static String getMode5JSONString(String dictType, String dictAttr) {
		BaseSelect baseSelect = SelectFactory.createBaseSelect();
		baseSelect.addNone();

		DataDictionaryInfo dataDictionaryInfo = null;
		List dictList = DataDictionaryManage.getDataDictionaryMap().get(dictType);
		if (dictList != null) {
			for (int i = 0; i < dictList.size(); i++) {
				dataDictionaryInfo = (DataDictionaryInfo) dictList.get(i);
				String dictattr = dataDictionaryInfo.getDictAttr();
				if (dictAttr.equals(dictattr))
					baseSelect.addOption(dataDictionaryInfo.getDictCode(), dataDictionaryInfo.getDictName());
			}
		}

		return baseSelect.getJSONSelectInfo();
	}

	/**
	 * CardTypeName
	 * 
	 * @param dictType
	 *            CardTypeName
	 * @param dictattr
	 *            数据属性
	 * @return 根据用户选择的卡类型 选择其下所有卡种名称
	 */
	public static String getMode6JSONString(String dictType, String dictAttr) {
		BaseSelect baseSelect = SelectFactory.createBaseSelect();
		baseSelect.addAll();
		DataDictionaryInfo dataDictionaryInfo = null;
		List dictList = DataDictionaryManage.getDataDictionaryMap().get(dictType);
		if (dictList != null) {
			for (int i = 0; i < dictList.size(); i++) {
				dataDictionaryInfo = (DataDictionaryInfo) dictList.get(i);
				String dictattr = dataDictionaryInfo.getDictAttr();
				if (dictAttr.equals(dictattr))
					baseSelect.addOption(dataDictionaryInfo.getDictCode(), dataDictionaryInfo.getDictName());
			}
		}

		return baseSelect.getJSONSelectInfo();
	}

	// 模式一
	public static String getMode1JSONString(String dictType) {

		BaseSelect baseSelect = SelectFactory.createBaseSelect();

		DataDictionaryInfo dataDictionaryInfo = null;
		List dictList = DataDictionaryManage.getDataDictionaryMap().get(dictType);

		if (dictList != null) {
			for (int i = 0; i < dictList.size(); i++) {
				dataDictionaryInfo = (DataDictionaryInfo) dictList.get(i);
				baseSelect.addOption(dataDictionaryInfo.getDictCode(), dataDictionaryInfo.getDictName());
			}
		}

		return baseSelect.getJSONSelectInfo();
	}

	// 模式二
	public static String getMode2JSONString(String dictType) {

		BaseSelect baseSelect = SelectFactory.createBaseSelect();

		baseSelect.addNone();

		DataDictionaryInfo dataDictionaryInfo = null;
		List dictList = DataDictionaryManage.getDataDictionaryMap().get(dictType);

		if (dictList != null) {
			for (int i = 0; i < dictList.size(); i++) {
				dataDictionaryInfo = (DataDictionaryInfo) dictList.get(i);
				baseSelect.addOption(dataDictionaryInfo.getDictCode(), dataDictionaryInfo.getDictName());
			}
		}

		return baseSelect.getJSONSelectInfo();
	}

	// 模式二-事件号
	public static String getModeEventJSONString(String dictType, boolean none) {

		BaseSelect baseSelect = SelectFactory.createBaseSelect();
		if (none) {

			baseSelect.addNone();
		}

		DataDictionaryInfo dataDictionaryInfo = null;
		List dictList = DataDictionaryManage.getDataDictionaryMap().get(dictType);

		if (dictList != null) {
			for (int i = 0; i < dictList.size(); i++) {
				dataDictionaryInfo = (DataDictionaryInfo) dictList.get(i);
				baseSelect.addOption(dataDictionaryInfo.getDictCode(), dataDictionaryInfo.getDictName());
			}
		}

		return baseSelect.getJSONSelectInfo();
	}

	// 模式三
	public static String getMode3JSONString(String dictType) {

		BaseSelect baseSelect = SelectFactory.createBaseSelect();

		baseSelect.addAll();

		DataDictionaryInfo dataDictionaryInfo = null;
		List dictList = DataDictionaryManage.getDataDictionaryMap().get(dictType);

		if (dictList != null) {
			for (int i = 0; i < dictList.size(); i++) {
				dataDictionaryInfo = (DataDictionaryInfo) dictList.get(i);
				baseSelect.addOption(dataDictionaryInfo.getDictCode(), dataDictionaryInfo.getDictName());
			}
		}

		return baseSelect.getJSONSelectInfo();
	}

	// 门店商户号维护第三方结算机构
	public static String getModeCustomerJSONString(String dictType) {

		BaseSelect baseSelect = SelectFactory.createBaseSelect();

		baseSelect.addAll_();

		DataDictionaryInfo dataDictionaryInfo = null;
		List dictList = DataDictionaryManage.getDataDictionaryMap().get(dictType);

		if (dictList != null) {
			for (int i = 0; i < dictList.size(); i++) {
				dataDictionaryInfo = (DataDictionaryInfo) dictList.get(i);
				baseSelect.addOption(dataDictionaryInfo.getDictCode(), dataDictionaryInfo.getDictName());
			}
		}

		return baseSelect.getJSONSelectInfo();
	}

}
